import request from "@/utils/request";
import type { ResponseData } from "@/api/user/type";
import type { MenuList } from "../role/type";
import type { MenuParams } from "./type";
enum API {
  //获取菜单
  PERMISSION_URL = "/admin/acl/permission",
  //添加菜单
  ADDPERMISSION_URL = "/admin/acl/permission/save",
  //修改菜单
  UPDATEPERMISSION_URL = "/admin/acl/permission/update",
  //删除菜单
  REMOVEPERMISSION_URL = "/admin/acl/permission/remove/",
}
//获取菜单
export const reqGetHasPermission = () => {
  return request.get<any, ResponseData<MenuList[]>>(API.PERMISSION_URL);
};
//添加｜修改菜单
export const reqAddOrUpdatePermission = (data: MenuParams) => {
  if (data.id) {
    return request.put<any, any>(API.UPDATEPERMISSION_URL, data);
  } else {
    return request.post<any, any>(API.ADDPERMISSION_URL, data);
  }
};
//删除菜单
export const reqRemovePermission = (id: number) => {
  return request.delete<any, any>(API.REMOVEPERMISSION_URL + `${id}`);
};
